import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
import tensorflow.examples.tutorials.mnist.input_data as input_data


def plot_image(image):
    plt.imshow(image.reshape(28, 28), cmap='binary')
    plt.show()


def plot_images_labels_prediction(images, labels, prediction, idx, num=100):
    fig = plt.gcf()
    fig.set_size_inches(12, 14)
    if num > 25: num = 25
    for i in range(0, num):
        ax = plt.subplot(5, 5, 1 + i)

        ax.imshow(np.reshape(images[idx], (28, 28)), cmap='binary')

        title = "label=" + str(np.argmax(labels[idx]))
        if len(prediction) > 0:
            title += ",predcit=" + str(prediction[idx])

        ax.set_title(title, fontsize=10)
        ax.set_xticks([]);
        ax.set_yticks([])
        idx += 1
    #plt.plot()
    plt.show()


mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
plot_images_labels_prediction(mnist.train.images, mnist.train.labels,
                              []
                              , 0)
print('train:', mnist.train.num_examples,
      ',validation ', mnist.validation.num_examples,
      ',test ', mnist.test.num_examples)
